package com.ruoyi.exam.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.exam.mapper.TPointsRulesMapper;
import com.ruoyi.exam.domain.TPointsRules;
import com.ruoyi.exam.service.ITPointsRulesService;

/**
 * 积分规则Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-01-13
 */
@Service
public class TPointsRulesServiceImpl implements ITPointsRulesService 
{
    @Autowired
    private TPointsRulesMapper tPointsRulesMapper;

    /**
     * 查询积分规则
     * 
     * @param id 积分规则主键
     * @return 积分规则
     */
    @Override
    public TPointsRules selectTPointsRulesById(Long id)
    {
        return tPointsRulesMapper.selectTPointsRulesById(id);
    }

    /**
     * 查询积分规则列表
     * 
     * @param tPointsRules 积分规则
     * @return 积分规则
     */
    @Override
    public List<TPointsRules> selectTPointsRulesList(TPointsRules tPointsRules)
    {
        return tPointsRulesMapper.selectTPointsRulesList(tPointsRules);
    }

    /**
     * 新增积分规则
     * 
     * @param tPointsRules 积分规则
     * @return 结果
     */
    @Override
    public int insertTPointsRules(TPointsRules tPointsRules)
    {
        tPointsRules.setCreateTime(DateUtils.getNowDate());
        return tPointsRulesMapper.insertTPointsRules(tPointsRules);
    }

    /**
     * 修改积分规则
     * 
     * @param tPointsRules 积分规则
     * @return 结果
     */
    @Override
    public int updateTPointsRules(TPointsRules tPointsRules)
    {
        tPointsRules.setUpdateTime(DateUtils.getNowDate());
        return tPointsRulesMapper.updateTPointsRules(tPointsRules);
    }

    /**
     * 批量删除积分规则
     * 
     * @param ids 需要删除的积分规则主键
     * @return 结果
     */
    @Override
    public int deleteTPointsRulesByIds(Long[] ids)
    {
        return tPointsRulesMapper.deleteTPointsRulesByIds(ids);
    }

    /**
     * 删除积分规则信息
     * 
     * @param id 积分规则主键
     * @return 结果
     */
    @Override
    public int deleteTPointsRulesById(Long id)
    {
        return tPointsRulesMapper.deleteTPointsRulesById(id);
    }

    @Override
    public Map<String, Object> getUserTotalPointsAndRank(Long userId) {
        return tPointsRulesMapper.getUserTotalPointsAndRank(userId);
    }
}
